//配置路由

import Layout from '@/pages/Layout'
import Login from '@/pages/Login'
import NotFound from '../pages/NotFound'
import { createBrowserRouter } from 'react-router-dom'
import { AuthRoute } from '@/components/AuthRoute'

// import Home from '@/pages/Home'
// import Article from '@/pages/Article'
// import Publish from '@/pages/Publish'
import { lazy, Suspense } from 'react'


const Home = lazy(() => import('@/pages/Home'))
const Article = lazy(() => import('@/pages/Article'))
const Publish = lazy(() => import('@/pages/Publish'))


//配置路由实例
const router = createBrowserRouter([
    {
        path: '/',
        // element: <Layout />,
        element: <AuthRoute><Layout /></AuthRoute>,
        children: [
            {
                index: true,     //默认二级路由
                // path:'home',
                element: <Suspense fallback={'加载中'}><Home /></Suspense>
            },
            {
                path: 'article',
                element: <Suspense fallback={'加载中'}><Article /></Suspense>
            },
            {
                path: 'publish',
                element: <Suspense fallback={'加载中'}><Publish /></Suspense>
            }
        ]
    },
    {
        path: '/login',
        element: <Login />,
    },
    {
        path: '*',
        element: <NotFound />,
    }
])

export default router
